import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'

//可将路由分到其他模块文件，再手动导入，注入路由
import children from './children'

//路由集合
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Index',
    component: () => import('@/views/home/index.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue')
  },

  ...children,

  // 无匹配时重定向至首页
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  },
]

//创建路由实例
const router = createRouter({
  //使用hash或者history模式
  history: createWebHashHistory(),

  routes,
})

// 导出路由实例
export default router